package storage;

import java.io.*;

import storage.Persistent;

public class User extends Persistent {

	private String name, login, pass;
	private int age;
	
	// Always need a default constructor
	public User() { }
	
	public User(String n, String l, String p, int a) {
		name = n;
		login = l;
		pass = p;
		age = a;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}
	
	// write the attributes
	public void writeObject(DataOutput dout) throws IOException {
		dout.writeUTF(name);
		dout.writeUTF(login);
		dout.writeUTF(pass);
		dout.writeInt(age);
	}

	// read the attributes in the same order that you write
	public void readObject(DataInput din) throws IOException {
		name = din.readUTF();
		login = din.readUTF();
		pass = din.readUTF();
		age = din.readInt();
	}

	public String toString() {
		return "(" + getId() + "," + name + "," + login + "," + pass + ")";
	}

}
